<template>
	<view class="home-layout">
		<!-- <custom-nav-bar :title="ProjectName"></custom-nav-bar> -->
        <custom-nav-bar></custom-nav-bar>
		<!-- Banner Section -->
		<view class="banner">
			<swiper circular :autoplay="true" :interval="5000" indicator-color="rgba(255, 255, 255, 0.6)"
				indicator-active-color="#ffffff" indicator-dots duration="1000">
				<swiper-item>
					<image src="../../common/images/wallpaper/banner1.jpg" mode="aspectFill"></image>
				</swiper-item>
				<swiper-item>
					<image src="../../common/images/wallpaper/banner2.jpg" mode="aspectFill"></image>
				</swiper-item>
				<swiper-item>
					<image src="../../common/images/wallpaper/banner4.jpg" mode="aspectFill"></image>
				</swiper-item>
			</swiper>
		</view>

		<view class="titleName">
			<commomn-title>
				<template #name>功能导航</template>
			</commomn-title>
		</view>
		<!-- Feature Cards Section -->
		<view class="section">
			<view class="card-grid">
				<!-- Schedule Card -->
				<view class="feature-card" @click="handleNavigation('/pages/schedule/schedule')">
					<view class="card-content">
						<view class="card-left">
							<text class="card-title">我的课表</text>
							<text class="card-desc">点击查看详细课程安排</text>
						</view>
						<view class="card-right">
							<uni-icons type="calendar" size="28" color="#2196F3"></uni-icons>
						</view>
					</view>
				</view>

				<!-- Homework Card -->
				<view class="feature-card" @click="handleNavigation('/pages/homework/homework')">
					<view class="card-content">
						<view class="card-left">
							<text class="card-title">我的作业</text>
							<text class="card-desc">查看发布的作业</text>
						</view>
						<view class="card-right">
							<uni-icons type="bars" size="28" color="#4CAF50"></uni-icons>
						</view>
					</view>
				</view>

				<!-- Diary Card -->
				<view class="feature-card" @click="handleNavigation('/pages/diary/diary')">
					<view class="card-content">
						<view class="card-left">
							<text class="card-title">填写日志</text>
							<text class="card-desc">记录每日学习</text>
						</view>
						<view class="card-right">
							<uni-icons type="compose" size="28" color="#FF9800"></uni-icons>
						</view>
					</view>
				</view>

		<!-- 		Upcoming Feature Card
				<view class="feature-card disabled">
					<view class="card-content">
						<view class="card-left">
							<text class="card-title">待开发</text>
							<text class="card-desc">正在开发中</text>
						</view>
						<view class="card-right">
							<uni-icons type="star" size="28" color="#9C27B0"></uni-icons>
						</view>
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		onMounted
	} from 'vue';
	import {
		apiVerifyToken
	} from '../../api/apis';

	const ProjectName = ref('');

	const bannerImages = [
		'../../common/images/wallpaper/banner1.jpg',
		'../../common/images/wallpaper/banner2.jpg',
		'../../common/images/wallpaper/banner3.jpg'
	];

	const handleNavigation = (url) => {
		uni.navigateTo({
			url
		});
	};

	onMounted(() => {
		uni.getStorage({
			key: "studentInfo",
			success: function(res) {
				const studentVO = res.data;
				ProjectName.value = studentVO.project.projectName;
			}
		});
	});
</script>

<style lang="scss" scoped>
	.home-layout {
		background-color: linear-gradient(to bottom, #f8f9fa, #f5f7fa);
	}


	.banner {
		// padding: 20rpx 30rpx;
		// width: 750rpx;
		width: 750rpx;
		padding: 30rpx 0;

		swiper {
			// width: 100%;
			// height: 340rpx;
			// border-radius: 16rpx;
			// overflow: hidden;
			// box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
			width: 750rpx;
			height: 340rpx;

			swiper-item {
				width: 100%;
				height: 100%;
                padding: 0 30rpx;   
                
				image {
					width: 100%;
					height: 100%;
					border-radius: 16rpx;
					transition: transform 0.3s ease;

				}
			}
		}
	}

	.titleName {
		margin-top: 7rpx;
	}

	.section {
		// margin: 0 30rpx;
		margin: 0 30rpx;
	}

	.card-grid {
		display: flex;
		flex-direction: column;
		gap: 30rpx;
		margin-top: 20rpx;
	}

	.feature-card {
		background: #ffffff;
		margin-top: 20rpx;
		border-radius: 25rpx;
		padding: 30rpx;
		box-shadow: 0 8rpx 10rpx rgba(0, 0, 0, 0.1);
		transition: transform 0.2s ease, box-shadow 0.2s ease;

		&:active {
			transform: translateY(3rpx);
			box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.04);
		}

		&.disabled {
			opacity: 0.6;
			pointer-events: none;
		}

		&:hover {
			background-color: rgba(255, 255, 255, 0.9);
			transform: scale(1.02);
		}

		.card-content {
			display: flex;
			justify-content: space-between;
			align-items: center;
		}

		.card-left {
			flex: 1;

			.card-title {
				font-size: 36rpx;
				font-weight: 700;
				color: #222;
				margin-bottom: 8rpx;
				display: block;
			}

			.card-desc {
				font-size: 26rpx;
				color: #555;
			}
		}

		.card-right {
			// background: #f8f9fa;
			width: 90rpx;
			height: 90rpx;
			border-radius: 45rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
</style>